<?php
class MasterController {
	public function doControll() {
		$title = "labb3";
		$page;
		// Create container
		$pageView = new PageView();
		$body;

		// Show register-view if user clicked that link
		if (isset($_GET["register"])) {
			// men inte om en redan är inloggad ju && !isloggedin()
			$registerController = new RegisterController();
			$main = $registerController -> doRegisterController();
		} else {
			// Else show login-view
			$loginController = new LoginController();
			$main = $loginController -> DoLoginControll();

			// Create instance of FileUploadController and add it to the body-variable
			$fileUploadController = new FileUploadController();
			$main .= $fileUploadController -> doFileUpload();
		}
		// Create menu
		$loginHandler = new LoginHandler();
		$linksarray[] = "<a href='index.php'>hem</a>";
		// If user is not logged in, add register link
		if(!$loginHandler->isLoggedIn()){
			$linksarray[] = "<a href='?register=true'>registrering</a>";	
		}
		$body = $pageView->createHeader($linksarray);
		//Add main content
		$body .= $main;
		// Add footer
		$body .= $pageView->createFooter("Lisa Övermyr - Webbutveckling med PHP");
		// Create XHTML-page
		$page = $pageView->getXHTMLPage($title, $body);
		return $page;
	}

}
